package dao

import (
	"github.com/jinzhu/gorm"
	"go-admin/internal/model"
)

// 批量添加
func (d *Dao) CreateCasbin(tx *gorm.DB, pType, roleKey string, menus []*model.Menu) error {
	casbinRule := model.CasbinRule{}
	return casbinRule.Create(tx, pType, roleKey, menus)
}

// 批量删除
func (d *Dao) DeleteCasbin(tx *gorm.DB, pType, roleKey string) error {
	casbinRule := model.CasbinRule{}
	return casbinRule.DeleteCasbin(tx, pType, roleKey)
}

// 批量添加user roleKey
func (d *Dao) CreateCasbinUserRole(tx *gorm.DB, pType, username string, roles []*model.Role) error {
	casbinRule := model.CasbinRule{}
	return casbinRule.CreateCasbinUserRole(tx, pType, username, roles)
}

func (d *Dao) DeleteCasbinUserRole(tx *gorm.DB, pType, username string) error {
	casbinRule := model.CasbinRule{}
	return casbinRule.DeleteCasbinUserRole(tx, pType, username)
}
